package cn.com.bluemoon.daps.model.core.file;

import cn.com.bluemoon.daps.common.domain.BaseModel;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.model.entity.DapDataModel;

@FunctionalInterface
public interface IConvertToModel<T extends BaseModel<T>> {
    ResultBean<T> convertToModel(DapDataModel model);

    /**
     * 是1
     *
     * @param bool
     * @return 1
     */
    default Integer isOne(Boolean bool) {
        if (bool == null) {
            return 0;
        }
        return Boolean.TRUE.equals(bool) ? 1 : 0;
    }

    default Integer isZero(Boolean bool) {
        if (bool == null) {
            return 0;
        }
        return Boolean.FALSE.equals(bool) ? 0 : 1;
    }
}
